<?php
/**
 * @package mikrokosmos
 * main configuration file on oct-2004
 * jaco_at_pixeldump_dot_org
 */

// security
//

//-editable settings---------------------------------------------------------

/*
 * the only thing you must set, examples:
 * $rootDir = "c:\\Apache\\Apache2\\htdocs\\mk"; // --> windows
 * $rootDir = "/var/www/html"; // --> linux, local dev
 * $rootDir = "/web/htdocs/www.yoursitename.com/home/mk"; // --> deploy
 * please note the lack of last "/" or "\"
 */

// absolute path to mk
//$rootDir = "/var/www/mk";

if(!strlen($rootDir) || !file_exists($rootDir)) die ("rootDir not set in config.inc.php, please read inst. notes in mk user guide");

// some LOCAL settings, comment out these line if you work with isp hosting plans
ini_set("max_execution_time", 300);
ini_set("memory_limit", "128M");
// time settings, accommodate to your locale
putenv("TZ=Europe/Rome");

//----------------------------------------------------------
// please do not edit below this line
// modify at your own risk

$mkConfig = array();
$debugMode = null;
$workingSwfVersion = null;

$mkConfig["root"]    = $rootDir;
$mkConfig["lib"]     = $rootDir ."/lib/"; 			 // function libraries
$mkConfig["classes"] = $rootDir ."/classes/"; 		 // classes
$mkConfig["media"]   = $rootDir ."/media/"; 		 // root contribs
$mkConfig["flash"]   = $mkConfig["media"] ."flash/"; // movies
$mkConfig["code"]    = $mkConfig["media"] ."code/";  // flasm and other syntax files
$mkConfig["fonts"]   = $mkConfig["media"] ."fonts/"; // fonts (mk format)
$mkConfig["svg"]     = $mkConfig["media"] ."svg/"; 	 // svg files
$mkConfig["snd"]     = $mkConfig["media"] ."snd/";   // sound data
$mkConfig["images"]  = $mkConfig["media"] ."imgs/";  // images
$mkConfig["ut"]      = $mkConfig["media"] ."ut/";    // unordered tags
$mkConfig["bck"]     = $mkConfig["media"] ."bcks/";  // movie or other backups
$mkConfig["tmp"]     = $rootDir ."/tmp/";   // temporary folder


// other paths, used for development and web publishing
$mkConfig["site"]    = $rootDir ."/site/"; // movie or other backups
$mkConfig["support"] = $mkConfig["site"]  ."support/"; //
$mkConfig["tpl"]     = $mkConfig["site"] ."/site_tpl/"; // templates
$mkConfig["css"]   = "css/";									   // css folder for web publish
$mkConfig["js"]    = "js/"; 									   // javascript
$mkConfig["imgs"]  = "imgs/";								   // image files
$mkConfig["swf"]   = "swf/";								   // web publish movies

// debug modes
define("DEBUG_MODE_NONE", 	 0x80); // no debug
define("DEBUG_MODE_BROWSER", 0x01); // traces on browser
define("DEBUG_MODE_LOG", 	 0x02); // write to log file
define("DEBUG_MODE_RETURN",  0x04); // returns trace value to caller
define("DEBUG_MODE_ALL", 	 0x0F); // all active modes available

// binary zero
define("NIL", chr(0));
define("WORD0", NIL .NIL);
define("DWORD0", WORD0 .WORD0);

// some html/xml/string tags
define("BR", "<br />");
define("SP", "&nbsp;");
define("XML_HEADER", "<?xml version=\"1.0\"?>");
define("NL", "\r\n");

// swf measure unit
define("TWIP", 20);

// radiant conversion
define("RADIANT", deg2rad(1));

// some classes error definition
define("STAT_OK", 1);
define("STAT_ERROR", 2);
define("STAT_NOTASWF", 3);
define("STAT_FILENOTFOUND", 4);

define("INSTANCE_EMPTY", 10);
define("INSTANCE_PENDING", 11);
define("INSTANCE_READY", 12);


// swf defaults
define("SWF_DEFAULT_NAME", "untitled.swf");
define("SWF_DEFAULT_VERSION", 6);
define("SWF_DEFAULT_STAGEWIDTH", 550);
define("SWF_DEFAULT_STAGEHEIGHT", 400);
define("SWF_DEFAULT_FPS", 12);
define("SWF_DEFAULT_BACKGROUNDCOLOR", "#FFFFFF");

// maximum RECT byte length
define("MAX_RECT_LENGTH", "17"); // ceil((15 * 4 + 5) / 8)
define("MAX_SHAPERECORD_LENGTH", "15"); // max byte length of a sr

// item definitions
define("ACTION_ITEM", "DoActionTag");
define("INITCLIP_ITEM", "DoInitActionTag");

define("DEBUGGER", 0);					// EnableDebugger version flag
define("DEBUGGER2", 1);					// EnableDebugger2 version flag
define("SHAPE_ITEM", "DefineShape");
define("SHAPE",  "DefineShape");
define("SHAPE2", "DefineShape2");
define("SHAPE3", "DefineShape3");

define("SHAPE_ID", 	2);					// 0x02
define("SHAPE_ID2", 22);				// 0x16
define("SHAPE_ID3", 32);				// 0x20
define("SHAPE_ID4", 131);				// 0x83
define("FONT", 		10);				// 0x0A
define("ACTIONS", 	12);				// 0x0C
define("INITCLIP", 	59);				// 0x3B
define("LINKAGE", 	56);				// 0x38
define("PLACEOBJECT2", 26);				// 0x1A
define("PLACEOBJECT3", 70);				// 0x46
define("BUTTON", 7);					// 0x07
define("BUTTON2", 34);					// 0x22
define("BUTTON_SOUND", 17);				// 0x11
define("TEXTFIELD", 37);				// 0x25
define("MOVIECLIP", 39);				// 0x27
define("TEXT", 	11);					// 0x0B
define("TEXT2",	33);					// 0x21
define("FONT2", 	48);				// 0x30
define("FONT3", 	75);				// 0x4B
define("FLASHTYPE", 73);				// 0x49
define("TEXTSETTINGS", 74);				// 0x4A
define("FRAME_LABEL", 43);				// 0x2B
define("SOUND", 14);					// 0x0E

// swf9 tag types
define("AS3CLASSNAMES", 76);			// 0x4C
define("AS3SCENENAMES", 86);			// 0x56


// sound definitions
define("SOUND_UNCOMPRESSED", 0);
define("SOUND_ADPCM", 1);
define("SOUND_MP3", 2);
define("SOUND_UNCOMPRESSED_LE", 3);		// uncompressed little-endian
define("SOUND_NELLYMOSER", 6);

define("RATE_5K5", 0);					// 5.5 KHz, not supported by mp3
define("RATE_11", 1);					// 11 KHz
define("RATE_22", 2);					// 22 KHz
define("RATE_44", 3);					// 44 KHz

define("SOUND_8BIT", 0);				// 8bit sample deep
define("SOUND_16BIT", 1);				// 16bit sample deep

define("SOUND_MONO", 0);				// mono, forced to zero for nellymoser
define("SOUND_STEREO", 1);				// stereo

define("SOUND_SH", 18);
define("SOUND_SH2", 45);

// mp3 versions & definitions
define("MP3_FRAME_SYNC", 0xFFE00000);
define("MP3_VERSION", 0x00180000);
define("MP3_VERSION_25", 0x00000000);
define("MP3_VERSION_RESERVED", 0x00080000);
define("MP3_VERSION_2", 0x00100000);
define("MP3_VERSION_1", 0x00180000);

define("MP3_LAYER", 0x00060000);
define("MP3_LAYER_RESERVED", 0x00000000);
define("MP3_LAYER_3", 0x00020000);
define("MP3_LAYER_2", 0x00040000);
define("MP3_LAYER_1", 0x00060000);


define("MP3_SAMPLERATE", 0x00000C00);
define("MP3_SAMPLERATE_SHIFT", 10);

define("MP3_CHANNEL", 0x000000C0);
define("MP3_CHANNEL_STEREO", 0x00000000);
define("MP3_CHANNEL_JOINT", 0x00000040);
define("MP3_CHANNEL_DUAL", 0x00000080);
define("MP3_CHANNEL_MONO", 0x000000C0);

// fillstyle fill types
define("SOLID_FILL","0");				// 0x00
define("LINEAR_GRADIENT_FILL", 	16);	// 0x10
define("RADIAL_GRADIENT_FILL", 	18);	// 0x12
define("FOCAL_RADIAL_GRADIENT_FILL", 19);	// 0x13
define("REPEATING_BITMAP_FILL", 64);	// 0x40
define("CLIPPED_BITMAP_FILL", 	65);	// 0x41
define("NS_BITMAP_FILL",		66);	// 0x42
define("NS_CLIPPED_BITMAP_FILL", 67);	// 0x43
define("GS_PAD", 0);					// gradient PAD mode
define("GS_REFLECT", 1);				// gradient REFLECT mode
define("GS_REPEAT", 2);					// gradient REPEAT mode
define("GRADIENT", 1);					// used by MK_gradient class
define("FOCAL_GRADIENT", 2);			// ... for swf8 and higher versions


// used in stylechange records and related
define("NO_STYLE",		0);				// 0x00
define("RIGHT_FILL",	1);				// 0x01
define("LEFT_FILL",		2);				// 0x02
define("BOTH_FILL",		3);				// 0x03
define("LINE_STYLE",	4);				// 0x04
define("ALL_STYLE",		7);				// 0x07
define("AUTO_FILL",		8);				// 0x08
define("HAS_NEW_STYLE", 16);			// 0x10


define("MOVIECLIP_ITEM", "DefineSprite");
define("BUTTON_ITEM",	 "DefineButton");
define("IMAGE_ITEM",	 "DefineBits");
define("VIDEO_ITEM",	 "DefineVideo");
define("SOUND_ITEM",	 "DefineSound");
define("FONT_ITEM",		 "DefineFont");
define("FONT_ITEM2",	 "DefineFont2");
define("TEXTFIELD_ITEM", "DefineEditText");

// used in textField
define("INPUT_TEXT", 	 0);
define("DYNAMIC_TEXT",   1);
define("LEFT_ALIGN" , 	 0);
define("RIGHT_ALIGN" ,   1);
define("CENTER_ALIGN" ,  2);
define("JUSTIFY_ALIGN" , 3);

// image lossy
define("JPEG_TABLE", "JPEGTables");
define("JPEG", "DefineBits");
define("JPEG2", "DefineBitsJPEG2");
define("JPEG_ALPHA", "DefineBitsJPEG3");

// image lossless
define("IMAGE_LOSSLESS", "DefineBitsLossless");
define("IMG_LS_PALETTE_8", 3);						// 8bpp
define("IMG_LS_PALETTE_15", 4);						// 15 bpp
define("IMG_LS_RGB", 5);							// rgb

define("IMAGE_LOSSLESS_ALPHA", "DefineBitsLossless2");
define("IMG_LS_PALETTE_8_ALPHA", 3);
define("IMG_LS_RGB_ALPHA", 5);

// some jpeg type flag
define("JPEG_BASELINE", 1);
define("JPEG_PROGRESSIVE", 2);

// some png type flag
define("PNG_GRAY", 0);
define("PNG_RGB", 2);
define("PNG_PALETTE", 3);
define("PNG_GRAY_ALPHA", 4);
define("PNG_RGB_ALPHA", 6);

//egde records
define ("MAX_TWIPS", 57600);

define("IS_END_SHAPERECORD" , 0);
define("IS_STYLECHANGERECORD", 1);
define("IS_EDGERECORD", 2);
define("NOT_EDGERECORD", 4);
define("IS_NONEDGERECORD", 8);
define("NOT_NONEDGERECORD", 16);
define("IS_STRAIGHT_EDGERECORD", 32);
define("NOT_STRAIGHT_EDGERECORD", 64);
define("IS_CURVED_EDGERECORD", 128);
define("NOT_CURVED_EDGERECORD", 256);
define("VERTICAL_LINE", 512);
define("HORIZONTAL_LINE", 1024);

// blend modes (swf >= 8)
define("BLEND_NORMAL", 	   0);		// valid also if == 1
define("BLEND_LAYER", 	   2);
define("BLEND_MULTIPLY",   3);
define("BLEND_SCREEN", 	   4);
define("BLEND_LIGTHEN",    5);
define("BLEND_DARKEN", 	   6);
define("BLEND_ADD", 	   7);
define("BLEND_SUBTRACT",   8);
define("BLEND_DIFFERENCE", 9);
define("BLEND_INVER", 	   10);
define("BLEND_ALPHA", 	   11);
define("BLEND_ERASE", 	   12);
define("BLEND_OVERLAY",    13);
define("BLEND_HARDLIGHT",  14);

// button states for buttonRecord
define("STATE_HIT",  0x08);		// hit test state
define("STATE_DOWN", 0x04);		// down state
define("STATE_OVER", 0x02);		// over state
define("STATE_UP",   0x01);		// up state


// saving options
define("OUTPUT_FROM_RAWBODY", 1);
define("OUTPUT_FROM_FRAMELIST_SIMPLE", 2);
define("OUTPUT_FROM_FRAMELIST_COMPLEX", 3);
define("OUTPUT_FROM_RAWFRAMELIST", 4);

// add frame option
define("SIMPLE_FRAME", 1);
define("OBJECT_FRAME", 2);
define("RAW_FRAME", 3);


//ovverride some zend engine tokens if php < 5
if (!defined("T_ML_COMMENT")) define("T_ML_COMMENT", T_COMMENT);
else define("T_DOC_COMMENT", T_ML_COMMENT);


// action push option
define("AS_STRING", 0);		// 0 = string literal
define("AS_FP", 1);			// 1 = floating-point literal
define("AS_NULL", 2);			// 2 = null
define("AS_UNDEFINED", 3);	// 3 = undefined
define("AS_REGISTER", 4);		// 4 = register
define("AS_BOOL", 5);			// 5 = boolean
define("AS_DOUBLE", 6);		// 6 = double
define("AS_INT", 7);			// 7 = integer
define("AS_CONST8", 8);		// 8 = constant 8
define("AS_CONST16", 9);		// 9 = constant 16

define("AS_BYTE", 10);		// byte
define("AS_WORD", 11);		// word

define("NONE", 0);			// no-method
define("GET", 1);				// get method
define("POST", 2);			// post method


// clip events flags
define("KEY_UP",	 0x80);			// key release
define("KEY_DOWN",	 0x40);			// key press
define("MOUSE_UP",   0x20);			// mouse release
define("MOUSE_DOWN", 0x10);			// mouse down
define("MOUSE_MOVE", 0x08);			// mouse move
define("UNLOAD",	 0x04);			// clip unload
define("ENTERFRAME", 0x02);			// enterFrame
define("LOAD",		 0x01);			// load

define("DRAG_OVER",	 0x8000);			// dragOver
define("ROLL_OUT",	 0x4000);			// rollOut
define("ROLL_OVER",	 0x2000);			// rollover
define("RELEASE_OS", 0x1000);			// mouse release outside
define("RELEASE",	 0x0800);			// mouse release
define("PRESS",		 0x0400);			// mouse press
define("INITIALIZE", 0x0200);			// init
define("DATA", 		 0x0100);			// onData

// player 6 and above
define("EVENT",		 0x040000);			// event for swf7, otherwise 0
define("KEY_PRESS",	 0x020000);			// key pressed
define("DRAG_OUT",	 0x010000);			// drag outside

// some wav (sound file) constans
define("RIFF_LENGTH", 12);
define("FMT_LENGTH", 24);

// test to use correctly unpack
if(array_values (unpack ('L1L', pack ('V',1))) != 4) define ("CPU_ENDIAN", 1); // big endian
else define("CPU_ENDIAN", 0); // little endian


// mk paths
define("SERVER_MKROOT",    $mkConfig["root"]);
define("SERVER_MKLIB",     $mkConfig["lib"]);
define("SERVER_MKCLASSES", $mkConfig["classes"]);
define("SERVER_MKMEDIA",   $mkConfig["media"]);
define("SERVER_MKFLASH",   $mkConfig["flash"]);
define("SERVER_MKCODE",    $mkConfig["code"]);
define("SERVER_MKSVG",     $mkConfig["svg"]);
define("SERVER_MKSND",     $mkConfig["snd"]);
define("SERVER_MKFONTS",   $mkConfig["fonts"]);
define("SERVER_MKIMAGES",  $mkConfig["images"]);
define("SERVER_MKTAGS",    $mkConfig["ut"]);
define("SERVER_MKSUPPORT", $mkConfig["support"]);
define("SERVER_MKBACKUP",  $mkConfig["bck"]);
define("MK_LOG", 		   $mkConfig["tmp"] ."mk_log.php");
define("SERVER_MKTMP",     $mkConfig["tmp"]);

// site/support paths
define("SERVER_MKSITE",    $mkConfig["site"]);
define("SERVER_MKTPL",     $mkConfig["tpl"]);
define("SERVER_MKCSS",	   $mkConfig["css"]);
define("SERVER_MKJS",	   $mkConfig["js"]);
define("SERVER_MKIMGS",	   $mkConfig["imgs"]);
define("SERVER_MKSWF",	   $mkConfig["swf"]);

// function framework
require_once(SERVER_MKLIB ."mk_lib_swf.php");			  	// basic I/O swf
require_once(SERVER_MKLIB ."mk_lib_avm2.php");			  	// basic I/O swf (avm2)
require_once(SERVER_MKLIB ."mk_lib_actions.php");			// as1 & 2/AVM1 action model lib support
require_once(SERVER_MKLIB ."mk_lib_abc.php");				// abc (as3/AVM2) action model lib suport
require_once(SERVER_MKLIB ."mk_lib_swf9_bulk.php");			// very basic swf9 class library support
require_once(SERVER_MKLIB ."mk_lib_images.php");			// images
require_once(SERVER_MKLIB ."mk_lib_draw.php");				// drawing api
require_once(SERVER_MKLIB ."mk_lib_text.php");				// text
require_once(SERVER_MKLIB ."mk_lib_sound.php");				// sound
require_once(SERVER_MKLIB ."mk_lib_flasm.php");				// flasm statements and jump computing
require_once(SERVER_MKLIB ."mk_utils.php");					// generic
require_once(SERVER_MKLIB ."mk_lib_support.php");			// some specialized
require_once(SERVER_MKLIB ."mk_lib_svg.php");				// some svg internals
require_once(SERVER_MKLIB ."mk_html_utils.php");			// generic web publishing

// wrapper classes
require_once(SERVER_MKCLASSES ."mk_structures.php");		// some structure
require_once(SERVER_MKCLASSES ."mk_html.php");				// a bunch of html tags
require_once(SERVER_MKCLASSES ."mk_classes.php");			// generic and base classes
require_once(SERVER_MKCLASSES ."mk_cs_tags.php");			// some relevant tag
require_once(SERVER_MKCLASSES ."mk_cs_actionscript.php");	// the main actionscript
require_once(SERVER_MKCLASSES ."mk_cs_swf9_bulk.php");	    // bulk AS3 opcodes and tag types
require_once(SERVER_MKCLASSES ."display/mk_cs_draw.php");			// defineShape and styleRecords with drawing api
require_once(SERVER_MKCLASSES ."display/mk_cs_button.php");			// button/buttonSound
require_once(SERVER_MKCLASSES ."display/mk_cs_movieclip.php");		// defineSprite
require_once(SERVER_MKCLASSES ."display/mk_cs_text.php");			// textField
require_once(SERVER_MKCLASSES ."mk_cs_sound.php");			// sound and sound structures
require_once(SERVER_MKCLASSES ."mk_cs_flasm.php");			// flasm disassembler/assembler
require_once(SERVER_MKCLASSES ."xmllib.php");				// third party xml parser
require_once(SERVER_MKCLASSES ."display/mk_cs_svg.php");			// svg reader
require_once(SERVER_MKCLASSES ."mk_cs_mkml.php");			// neat experimental (yet inconsistent) swfreader/writer
require_once(SERVER_MKCLASSES ."composers/mk_composers.php");			// hi level macro "composers"
require_once(SERVER_MKCLASSES ."utils/penner_easing.php");		// penner's easing equations php port


session_start();

// set default (supposed) swf version working on
set_global_swfVersion();

// debugging mode
// DEBUG_MODE_NONE, silent
// DEBUG_MODE_BROWSER, echo variables on browser
// DEBUG_MODE_LOG, write traces on MK_LOG
// DEBUG_MODE_ALL, all these (but no DEBUG_MODE_NONE :D)
if(!$debugMode) $debugMode = DEBUG_MODE_BROWSER;
// -------- end of config ---------------------------
?>
